$(function() {
	$('#search_user').live('click', function() {
		adminUser.searchUser('page');
	});
	$('#export_user').live('click', function() {
		adminUser.searchUser('csv');
	});	
});

var adminUser = (function(){

	var searchUser = function(type) {
		var s_username = $('#s_username').val();
		var s_department = $('#s_department').val();
		var s_code = $('#s_code').val();
		var s_company = $('#s_company').val();
		var s_status = $('#s_status').val();
		var url = _siteUrl+'admincp/hecUser/index?search[s_username]='+encodeURI(s_username)+'&search[s_department]='+s_department+'&search[s_code]='+s_code+'&search[s_company]='+s_company+'&search[s_status]='+s_status+'&search[type]='+type;
		if(type=='csv') {
			window.open(url); 	
		} else if(type=='page'){
			document.location.href = url;
		}
	}
	
	return {
		searchUser : searchUser
	};
	
})();